package org.dromara.germbank.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.constant.SystemConstants;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.germbank.domain.BusChannelManagement;
import org.dromara.germbank.domain.BusOperationsAdvertisement;
import org.dromara.germbank.domain.bo.BusChannelManagementBo;
import org.dromara.germbank.domain.bo.BusOperationsAdvertisementBo;
import org.dromara.germbank.domain.vo.BusChannelManagementVo;
import org.dromara.germbank.mapper.BusChannelManagementMapper;
import org.dromara.germbank.service.BusChannelManagementService;
import org.springframework.stereotype.Service;

/**
 * 渠道管理Service
 *
 * @author congxing
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class BusChannelManagementServiceImpl implements BusChannelManagementService {
    private final BusChannelManagementMapper busChannelManagementMapper;

    @Override
    public TableDataInfo<BusChannelManagementVo> queryPageList(BusChannelManagementBo bo, PageQuery pageQuery) {

        Page<BusChannelManagementVo> page = busChannelManagementMapper.queryPageList(pageQuery.build(),this.buildQueryWrapper(bo));
        return TableDataInfo.build(page);
    }



    //分页查询条件
    private Wrapper<BusChannelManagement> buildQueryWrapper(BusChannelManagementBo bo) {
        return Wrappers.<BusChannelManagement>lambdaQuery()
            .eq(BusChannelManagement::getDelFlag, SystemConstants.NORMAL)
            .like(StringUtils.isNotBlank(bo.getChannelName()), BusChannelManagement::getChannelName, bo.getChannelName())
            .eq(StringUtils.isNotBlank(bo.getChannelCodePrefix()), BusChannelManagement::getChannelCodePrefix, bo.getChannelCodePrefix())
            .eq(StringUtils.isNotBlank(bo.getChannelState()), BusChannelManagement::getChannelState, bo.getChannelState())
            .orderByAsc(BusChannelManagement::getId);
    }
}




